package Q3;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        String str = scanner.next();

        int sCount = 0;
        int hCount = 0;
        int yCount = 0;

        long temp = 0;
        long ret = 0;
        for (int i = 0; i < n; i++) {
            char ch = str.charAt(i);
            if (ch == 's') {
                sCount++;
            } else if (ch == 'h') { //碰到 h 就算一下前面有多少个 s，防止将 h 后面的 s 也算进去
                temp += sCount;
            } else if (ch == 'y') {
                ret += temp;
            }
        }

        System.out.println(ret);
    }
}
